﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace ECSE6770.Models
{
    public class DirectPaymentModel
    {
        [Required]
        [Display(Name = "First Name")]
        public string FirstName { get; set; }

        [Required]
        [Display(Name = "Last Name")]
        public string LastName { get; set; }

        [Required]
        [Display(Name = "Card Type")]
        public string CardType { get; set; }

        [Required]
        [Display(Name = "Card Number")]
        public string CardNumber { get; set; }

        /* This is a string because maybe a leading 0 is significant? */
        [Required]
        public string ExpirationMonth { get; set; }

        [Required]
        public string ExpirationYear { get; set; }

        [Required]
        [Display(Name = "Card Verification Number")]
        public string CardVerificationNumber { get; set; }

        [Required]
        [Display(Name = "Address 1")]
        public string BillingAddress1 { get; set; }

        [Display(Name = "Address 2")]
        public string BillingAddress2 { get; set; }

        [Required]
        public string City { get; set; }

        [Required]
        public string State { get; set; }

        [Required]
        [Display(Name = "Zip Code")]
        public string ZipCode { get; set; }

        [Required]
        public string Country { get; set; }

        public string ObfuscateCardNumber()
        {
            if (!String.IsNullOrWhiteSpace(CardNumber))
            {
                string last4 = CardNumber.Substring(CardNumber.Length - 4);
                string obfuscated = "";
                for (int i = 0; i < CardNumber.Length - 4; i++)
                    obfuscated += "*";
                return obfuscated + last4;
            }
            else
                return String.Empty;
        }
    }
}